﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FlowNodeFramework.Node;
using Prism.Common;

namespace FlowNodeFramework.ViewModels
{
    public class MainViewModel : BindableBase
    {
      
        #region 属性
        public ObservableCollection<NodeItem> RootNodes { get; set; }
        #endregion

        #region 构造函数
        public MainViewModel()
        {
            InitTreeView();
        }
        #endregion

        #region 命令

        #endregion

        #region 本地方法
        #region 树节点初始化
        private void InitTreeView()
        {
            RootNodes = new ObservableCollection<NodeItem>
            {
                  new NodeItem
                  {
                        Name = "内置节点",
                        NodeType = NodeType.Parent,
                        Icon = "pack://application:,,,/Assets/Imgs/Lib.png",
                        Children = {
                              new NodeItem
                                {
                                Name = "函数节点",
                                NodeType = NodeType.Parent,
                                Icon = "pack://application:,,,/Assets/Imgs/Folder.png",
                                Children = {
                                    new NodeItem {
                                        Name = "运算函数",
                                        NodeType = NodeType.Parent,
                                        Icon = "pack://application:,,,/Assets/Imgs/Folder.png",
                                        Children =
                                        {
                                             new NodeItem { Name = "关系运算",NodeType = NodeType.Child, Icon = "pack://application:,,,/Assets/Imgs/NodePreset.png" }
                                        }
                                    },
                                    new NodeItem {
                                        Name = "执行控制",
                                        NodeType = NodeType.Parent,
                                        Icon = "pack://application:,,,/Assets/Imgs/Folder.png",
                                        Children =
                                        {
                                             new NodeItem { Name = "多线程执行", NodeType = NodeType.Child, Icon = "pack://application:,,,/Assets/Imgs/NodePreset.png" },
                                             new NodeItem { Name = "延迟执行", NodeType = NodeType.Child, Icon = "pack://application:,,,/Assets/Imgs/NodePreset.png" },
                                             new NodeItem { Name = "暂停执行", NodeType = NodeType.Child, Icon = "pack://application:,,,/Assets/Imgs/NodePreset.png" },
                                        }
                                    },
                                    new NodeItem
                                    {
                                        Name = "转换器",
                                        NodeType = NodeType.Parent,
                                        Icon = "pack://application:,,,/Assets/Imgs/Folder.png",
                                        Children = {
                                            new NodeItem { Name = "多线程执行", NodeType = NodeType.Child,Icon = "pack://application:,,,/Assets/Imgs/NodePreset.png" },
                                            new NodeItem { Name = "延迟执行", NodeType = NodeType.Child,Icon = "pack://application:,,,/Assets/Imgs/NodePreset.png" }
                                        }
                                    }
                                }
                            },
                              new NodeItem
                              {
                                  Name = "流程控制节点",
                                  NodeType = NodeType.Parent,
                                  Icon = "pack://application:,,,/Assets/Imgs/Folder.png",
                                  Children =
                                  {
                                      new NodeItem { Name = "计数循环", NodeType = NodeType.Child,Icon = "pack://application:,,,/Assets/Imgs/NodePreset.png" },
                                      new NodeItem { Name = "判断", NodeType = NodeType.Child,Icon = "pack://application:,,,/Assets/Imgs/NodePreset.png" },
                                      new NodeItem { Name = "条件循环", NodeType = NodeType.Child,Icon = "pack://application:,,,/Assets/Imgs/NodePreset.png" },
                                      new NodeItem { Name = "选择执行", NodeType = NodeType.Child,Icon = "pack://application:,,,/Assets/Imgs/NodePreset.png" },
                                  }
                              },
                              new NodeItem
                              {
                                  Name = "驱动节点",
                                  NodeType = NodeType.Parent,
                                  Icon = "pack://application:,,,/Assets/Imgs/Folder.png",
                                  Children =
                                  {
                                      new NodeItem { Name = "定时驱动器",NodeType = NodeType.Child, Icon = "pack://application:,,,/Assets/Imgs/NodePreset.png" },
                                      new NodeItem { Name = "帧驱动器", NodeType = NodeType.Child,Icon = "pack://application:,,,/Assets/Imgs/NodePreset.png" }
                                  }
                              },
                              new NodeItem
                              {
                                  Name = "事件节点",
                                  NodeType = NodeType.Parent,
                                  Icon = "pack://application:,,,/Assets/Imgs/Folder.png",
                                  Children =
                                  {
                                      new NodeItem { Name = "按键",NodeType = NodeType.Child, Icon = "pack://application:,,,/Assets/Imgs/NodePreset.png" }
                                  }
                              },
                              new NodeItem
                              {
                                  Name = "数据节点",
                                  NodeType = NodeType.Parent,
                                  Icon = "pack://application:,,,/Assets/Imgs/Folder.png",
                                  Children =
                                  {
                                      new NodeItem { Name = "小数", NodeType = NodeType.Child,Icon = "pack://application:,,,/Assets/Imgs/NodePreset.png" },
                                      new NodeItem { Name = "复数", NodeType = NodeType.Child,Icon = "pack://application:,,,/Assets/Imgs/NodePreset.png" },
                                      new NodeItem { Name = "字符串", NodeType = NodeType.Child,Icon = "pack://application:,,,/Assets/Imgs/NodePreset.png" }
                                  }
                              }
                        }
                  }
            };
        }
        #endregion

        #endregion
    }
}
